package WrittenTest;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class test26 {
    public static int n, m;
    public static Map<Integer, Integer> hash = new HashMap<>();
    public static int hashMap = 0;
    // 求出可以分成组的最少人数
    public static boolean check(int x) {
        int g = 0;
        for (int k : hash.values()) {
            g += k / x + (k % x == 0 ? 0 : 1);
        }
        return g <= m;
    }
    // 声部分组
    // 算法原理：二分 + 枚举
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        // 用哈希表统计每个声部的人数，并找出声部最多的人数
        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            hash.put(x, hash.getOrDefault(x, 0) + 1);
            hashMap = Math.max(hashMap, hash.get(x));
        }
        // 处理边界问题
        int kinds = hash.size();
        if (kinds > m) {
            System.out.println("-1");
        } else {
            // 暴力枚举
             for (int i = 1; i < hashMap; i++) {
                 if (check(i)) {
                     System.out.println(i);
                     break;
                 }
             }
            // 二分法
            int l = 1, r = hashMap;
            while (l < r) {
                int mid = (l + r) / 2;
                if (check(mid)) {
                    r = mid;
                } else {
                    l = mid + 1;
                }
            }
            System.out.println(l);
        }
    }
}